<?php
class Application_Form_Profile extends Zend_Form
{// all by ammar
    public function init()
    {   
        $validator = new Zend_Validate_Regex('([A-Za-z0-9]+)');
        $validator->setMessage(
            'Your username can only contain letters, numbers and underscores (_).');
        $validatorEmail = new Zend_Validate_EmailAddress();
        $validatorLength = new Zend_Validate_StringLength(array("min" => 6));

        $login = new Zend_Session_Namespace('login');
        $result= $login->userObj;

        $firstname = $this->createElement('text','fname');
        $firstname->setLabel('First Name:')
                    ->setRequired(false)
                    ->setValue($result[0]['fname'])
                    ->addValidator($validator)
                    ->addValidator($validatorLength);
                  
        $lastname = $this->createElement('text','lname');
        $lastname->setLabel('Last Name:')
                    ->setRequired(false)
                    ->setValue($result[0]['lname'])
                    ->addValidator($validator)
                    ->addValidator($validatorLength);

                    
        $email = $this->createElement('text','email');
        $email->setLabel('Email: *')
                ->setRequired(true)
                ->setValue($result[0]['email'])
                ->setAllowEmpty(false)
                ->addValidator($validatorEmail);
                
        $username = $this->createElement('text','username');
        $username->setLabel('Username: *')
                ->setRequired(true)
                ->setAllowEmpty(false)
                ->setValue($result[0]['username'])
                ->addValidator($validator)
                ->addValidator($validatorLength);
                
        $password = $this->createElement('password','password');
        $password->setLabel('Password: *')
                ->setRequired(true)
                ->setValue("hahah")
                ->setAllowEmpty(false)
                ->addValidator($validatorLength);
                
        $confirmPassword = $this->createElement('password','confirmPassword');
        $confirmPassword->setLabel('Confirm Password: *')
                ->setRequired(true)
                ->setValue("hahah")
                ->setAllowEmpty(false)
                ->addValidator($validatorLength);
      
        $save = $this->createElement('submit','save');
        $save->setLabel('save')
             ->setIgnore(true);
        
        $this->addElements(array(
                        $firstname,
                        $lastname,
                        $email,
                        $username,
                        $password,
                        $confirmPassword,
                        $save
        ));
    }
}

?>
